from PIL import Image, ExifTags
from PIL.ExifTags import TAGS

img = Image.open('/home/wc/disk1/datasets/CASIAV1/Modified_Tp/Sp/Sp_D_CNN_A_sec0012_ani0007_0275.jpg')

# print(img.info.keys())  # dict_keys(['exif', 'parsed_exif', 'dpi', 'photoshop', 'adobe', 'adobe_transform'])
# print(img.info['exif'])
# print(img._getexif())  # {40961: 65535, 40962: 960, 40963: 720, 296: 2, 34665: 168, 305: 'Adobe Photoshop CC 2019 (Windows)', 274: 1, 306: '2019:08:07 10:01:27', 282: (720000, 10000), 283: (720000, 10000)}

# Get the exif data of the image
exif_data = img._getexif()
# Create a dictionary to store the exif information
exif_info = {}
# Loop through the exif data items
for tag, value in exif_data.items():
    # Get the tag name from the TAGS dictionary
    tag_name = TAGS.get(tag, tag)
    # Update the exif_info dictionary with the tag name and value pair
    exif_info[tag_name] = value
print(exif_info)